/**
 * @Date: 2022-04-08 13:53:17
 * @LastEditors: sailornpg
 * @LastEditTime: 2022-04-12 13:11:50
 * @FilePath: \weibo-api\validator\user.js
 * @Description: 用户格式校验
 */
const validate = require("./validate");
// 用户检验规则
const SCHEMA = {
  type: "object",
  properties: {
    userName: {
      type: "string",
      maxLength: 255,
      minLength: 2,
    },
    password: {
      type: "string",
      maxLength: 255,
      minLength: 3,
    },
    newPassword: {
      type: "string",
      maxLength: 255,
      minLength: 3,
    },
    nickName: {
      type: "string",
      maxLength: 255,
    },
    avatar: {
      type: "string",
      maxLength: 255,
    },
    city: {
      type: "string",
      maxLength: 255,
      minLength: 2,
    },
    gender: {
      type: "string",
      maxLength: 1,
      minLength: 1,
    },
    type: {
      type: "string",
      maxLength: 10,
      minLength: 10,
    },
  },
};
//执行校验
function userValidate(data = {}) {
  return validate(SCHEMA, data);
}
module.exports = userValidate;
